﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Data.OleDb;
using ArkEC.CoreCom.Runtime;
using MySql.Data.MySqlClient;

namespace ArkEC.SEMs.DataAccess
{
    /// <summary>
    /// 数据库连接工厂
    /// </summary>
    public class ConnFactory
    {
        /// <summary>
        /// 创建数据库连接
        /// </summary>
        /// <returns></returns>
        public static DbConnection CreateConn()
        {
            DbConnection conn = null;
            string connType = RunSetting.ConnType;
            string connStr = string.Format(RunSetting.ConnStr, AppDomain.CurrentDomain.BaseDirectory);

            switch (connType)
            {
                case "OleDb":
                    conn = new OleDbConnection(connStr);
                    break;
                case "MySQL":
                    conn = new MySqlConnection(connStr);
                    break;
                default:
                    break;
            }

            return conn;
        }
    }
}
